package xyz.wanwanwan.www.hrm.feign.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import xyz.wanwanwan.www.hrm.domain.CoursePromotion;
import xyz.wanwanwan.www.hrm.util.AjaxResult;
import xyz.wanwanwan.www.hrm.fallbackfactory.FeignClientFallbackFactory;

@FeignClient(value = "cache-server",fallbackFactory = FeignClientFallbackFactory.class)
public interface CacheFeign {
    @PostMapping("/redis/set")
    AjaxResult setToRedis(@RequestParam("key") String key,
                          @RequestParam("value") String value);

    /**
     * 促销
     * @param coursePromotion
     * @return
     */
    @PostMapping("/redis/save")
    AjaxResult savePromotion(@RequestBody CoursePromotion coursePromotion);
    @PostMapping("/redis/getListCoursePromotion")
    AjaxResult getListCoursePromotion();
    @PostMapping("/redis/getBuyCoursePromotion/{id}")
    byte[] getBuyCoursePromotion(@RequestParam("id")Long id);
    /**
     * 从redis中获取
     * @PathVariable key /redis/get/username
     * @return
     */
    @GetMapping("/redis/get/{key}")
    AjaxResult getFromRedis(@PathVariable("key") String key);

    /**
     * 删除缓存
     * @param key
     * @return
     */
    @GetMapping("redis/del/{key}")
   AjaxResult delRedis (@PathVariable("key") String key);
    @PostMapping("redis/setex")
    AjaxResult setImageCodeToRedis(@RequestParam("key") String key,
                                          @RequestParam("seconds") int seconds,
                                          @RequestParam("value") String value);
}